<template>
	<view>
		<view class="flex  a-c "
			style="z-index: 9999;position: fixed;height: 90rpx;background-color: #fff;width: 100%;margin-top: -5rpx;">
			<view class="flex j-s a-c" style="padding-left: 60rpx;padding-right: 60rpx;width: 100%;">
				<view class="" @click="onnav(0)">
					<text>{{navname}}▼</text>
				</view>
				<view @click="onnav(1)">
					<text>{{tabb}}▼</text>
				</view>
			</view>

		</view>
		<view class="" style="height: 120rpx;">

		</view>
		<shopList :list="shop_list" :islog="islog" :log="log"> </shopList>
		<view class="" style="width: 50px;">
			<uni-popup ref="alertDialog" type="dialog">
				<uni-popup-nav cancelText="取消" :navnamea="tab_listb" confirmText="确认" :lei="lei" :NavList="NavList"
					@confirma="on_xza" @confirm="on_xz">
				</uni-popup-nav>
			</uni-popup>
		</view>

	</view>
</template>

<script>
	import shopList from "@/zu/ban_tongchengshop/shop_list.vue";
	import sort from '@/subPackages/common/zwx-sort/zwx-sort';
 
	export default {
		components: {
			shopList
		},
		data() {
			return {
				shop_list: [],
		 
				islog: true,
				log: '加载中',
				NavList: [],
				tabb: '智能排序',
				navname: '全部分类',
				tab_listb: [{
					"id": 2,
					"name": "智能排序",
					"sort": 0
				}, {
					"id": 3,
					"name": "离我最近",
					"sort": 1
				}, {
					"id": 4,
					"name": "最新入驻",
					"sort": 2
				}],
				lei: 0,
				nav_id: 0
			}
		},
		onLoad(on) {
			this.nav_id = on.id;
			this.page = 1;
			this.shop_init();
		},
		methods: {
			on_xz(id, name) {
				this.nav_id = id;
				this.shop_list = [];
				this.islog = true;
				this.page = 1;
				this.log = '加载中';
				this.navname = name;
				this.shop_init();

			},
			on_xza(id, name) {
				this.shop_list = [];
				this.islog = true;
				this.page = 1;
				this.log = '加载中';
				this.tabb = name;
				this.tabindex = id;
			 
				this.shop_init();
			},
			onnav(id) {
				this.lei = id;

				this.$refs.alertDialog.open('top')
			},
			shop_init() {
				var that = this;
				let requestParams = {
					user_id: uni.getStorageSync('user_id'),
					token: uni.getStorageSync('token'),
					page: this.page,
					tabindex: this.tabindex,
					nav_id: this.nav_id
				};
				 
				this.Htpp.post('plugin.php/banmi_tongcheng.index/shop_list', 'app', {
					token: false,
					datalist: requestParams

				}).then(ret => {
					// console.log("ret: " + JSON.stringify(ret));

					if (ret.data.status == 200) {
						if (that.page == 1) {
							this.shop_list = ret.data.data.shop_list;
							this.NavList = ret.data.data.NavList;
							if (this.nav_id>0) {
								for (var i = 0; i < this.NavList.length; i++) {
									if (this.nav_id==this.NavList[i]['id']) {
										this.navname =	this.NavList[i]['name']
									}  
								 
								}
							 
							}  

						} else {
							if (ret.data.data.shop_list.length > 0) {
								for (var i = 0; i < ret.data.data.shop_list.length; i++) {
									that.shop_list.push(ret.data.data.shop_list[i]);
								}
							}
							if (ret.data.data.shop_list < 10) {
								this.log = "没有数据了"
							}
						}
						setTimeout(() => {
							that.isinit = false;
							that.islog = false;
						}, 100)


					}



				})
			},

		}
	}
</script>

<style>

</style>
